import router from '@system.router'

var picker1value = null;
var picker2value = null;

var picker1seconds = null;

var timer1 = null;

export default {
    data: {
        seconds: 0,
        isshow: true,
        huxi: "吸气"
    },
    clickAction() {
        clearInterval(timer1);
        timer1 = null;

        router.replace({
            uri:'pages/index/index'
        });
    },
    run1() {
        this.seconds--;
        if (this.seconds == 0) {
            clearInterval(timer1);
            timer1 = null;
            this.isshow = false;
        }
    },
    onInit() {
        console.log("训练页面的onInit()被调用");

        console.log("接收到的左边选择器的值：" + this.data1);
        console.log("接收到的右边选择器的值：" + this.data2);

        picker1value = this.data1;
        picker2value = this.data2;

        if (picker1value == "1") {
            picker1seconds = 60;
        } else if (picker1value == "2") {
            picker1seconds = 120;
        } else if (picker1value == "3") {
            picker1seconds = 180;
        }

        this.seconds = picker1seconds;
    },
    onReady() {
        console.log("训练页面的onReady()被调用");
    },
    onShow() {
        console.log("训练页面的onShow()被调用");

        timer1 = setInterval(this.run1,1000);
    },
    onDestroy() {
        console.log("训练页面的onDestroy()被调用");
    }
}
